home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14934 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.0 KB  |  73 lines

  1. Path: sage.cgd.ucar.edu!jadams
  2. From: jadams@sage.cgd.ucar.edu (James Adams)
  3. Newsgroups: comp.lang.c++,gnu.g++.help
  4. Subject: Unable to compile inline functions
  5. Date: 2 Apr 1996 20:00:08 GMT
  6. Organization: National Center for Atmospheric Research
  7. Distribution: world
  8. Message-ID: <4js108$pm4@ncar.ucar.edu>
  9. Reply-To: jadams@sage.cgd.ucar.edu
  10. NNTP-Posting-Host: sage.cgd.ucar.edu
  11.  
  12. Hello,
  13.  
  14.     I am attempting to compile a C++ program which has member functions
  15. defined as inline, and I get unresolved errors from my linker.  For instance
  16. I have a class defined as such:
  17.  
  18. class nrifframe {
  19.   private:
  20.         // private member variables
  21.         int     count;
  22.         char    *filename;
  23.         FILE    *infile;
  24.         header  *head;
  25.         pix48   *data;
  26.   public:
  27.         // public member functions
  28.         nrifframe ();
  29.         ~nrifframe ();
  30.         bool    initialize (char *name);
  31.         int     getwidth ();
  32.         int     getheight ();
  33. };
  34.  
  35. I have defined the inline functions (in another file) as such:
  36.  
  37. inline int nrifframe::getheight()
  38. {
  39.   return(this->head->y);
  40. }
  41.  
  42. The errors I am getting from ld:
  43.  
  44. collect2: ld returned 1 exit status
  45. /bin/../lib/ld:
  46. Unresolved:
  47. nrifframe::getheight(void)
  48.  
  49.  
  50. I have a reference (C++ Complete, Schildt, p293) which shows this to be
  51. the correct method of declaring/defining inline functions.  Have I
  52. missed something ?  (I prefer this over the somewhat messy [but maybe
  53. more correct ?] method of defining the function on the same line as
  54. its declaration in the class declaration)
  55.  
  56. I am using g++ on an SGI Indy.
  57.  
  58. My command is "g++ -o executable main.cpp file1.cpp"
  59.  
  60.  
  61.     Thanks for any help/suggestions/advice !  Please email responses
  62. if possible.
  63.  
  64.  
  65. -James
  66. -- 
  67. ---------------------------------------------------------------------------
  68. James Adams                               Email: jadams@ucar.edu
  69. National Center for Atmospheric Research  Phone: (303) 497-1356
  70. Boulder, Colorado                         Fax:   (303) 497-1348
  71.  
  72.     WWW:  http://www.cgd.ucar.edu/ccr/jadams/home.html
  73.